<?php
session_start();
include("language.php");
include('database.php');

$_SESSION['curPage'] = 'idTicketByDraw.php';

if(isset($_SESSION['connected']) AND $_SESSION['connected'])
{
    if($_SESSION['access'] != 10)
    {
      header("Location: error.php");
    }
       
          if(isset($_POST['dt']))
          {
                $query=$db->query(" SELECT battletag, ticket_id FROM user U inner join drawparticipation  on U.id = user_id inner join draw DR on draw_id = DR.id where status = '2' order by ticket_id");
          }elseif(isset($_POST['tc']))
              {
                  $query=$db->query(" SELECT battletag, ticket_id FROM user U inner join drawparticipation  on U.id = user_id inner join draw DR on draw_id = DR.id where status = '1' order by ticket_id");
              }
              else 
                {
                  echo "Proute";
                }
}
else header("Location: error.php");
?>
<!DOCTYPE html>
<html>
    <head>
            <meta charset="utf-8" />
            <link rel="stylesheet" href="style.css" />
    </head>
    <body>
        <div class="d_body">
            <?php include('header.php'); ?>
             <br>
        <div class="d_menuBar">
        <ul class="menuBarTable">
           <li><a href="home.php">Acceuil</a></li>
           <li><a href="listMember.php">Liste des membres</a></li>
           <li><a href="addTickets.php">Ajout tickets</a></li>
           <li><a href="idTicketByDraw.php">Liste Ticket</a></li>
           </ul>
            </div> 
           <?php
            echo '<br><br/><br/><br/><br/><center><form method=post action="idTicketByDraw.php">
        <center><table class="listMember">';
        
         echo' <input type = submit name="dt" value=Dernier_Tirage></input>';
         echo '<input type = submit name="tc" value=Tirage_en_cours></input>';
        
         echo '<br><br/><br/><th class="td_listerMember">BattleTag</th><th class="td_listerMember">ID_Ticket</th>';
        
         while($data = $query->fetch()) 
         { 
             echo '<tr><td class="td_listerMember">'.$data['battletag'].'</td>';
             echo '<td class="td_listerMember">'.$data['ticket_id'].'</td>';
          }   
             echo '</table><center></form></center>';  
       
           ?>
        
       </div>
    </body>
</html>
        